package com.credithc.customers.dataservice.service.impl;

import com.credithc.customers.base.constants.CustomerConstants;
import com.credithc.customers.base.mapper.CustomerAccountMapper;
import com.credithc.customers.base.mapper.CustomerProductMapper;
import com.credithc.customers.base.service.ICommonService;
import com.credithc.customers.base.utils.CustomerUtils;
import com.credithc.customers.dataservice.constants.SyncTypeEnum;
import com.credithc.customers.dataservice.constants.TableNameConstants;
import com.credithc.customers.dataservice.mapper.CD.CommonMapper;
import com.credithc.customers.dataservice.mapper.CD.LesseeMapper;
import com.credithc.customers.dataservice.mapper.DLR.DlrMapper;
import com.credithc.customers.dataservice.mapper.HHRJKD.UsersMapper;
import com.credithc.customers.dataservice.mapper.HYD.HydMapper;
import com.credithc.customers.dataservice.mapper.HYR.HyrMapper;
import com.credithc.customers.dataservice.mapper.JHZF.JhzfMapper;
import com.credithc.customers.dataservice.mapper.XD.MicroloanUserMapper;
import com.credithc.customers.dataservice.mapper.XHQB2.Xhqb2Mapper;
import com.credithc.customers.dataservice.mapper.XT.EntrustUserMapper;
import com.credithc.customers.dataservice.po.*;
import com.credithc.customers.dataservice.ro.BinlogColumnRo;
import com.credithc.customers.dataservice.ro.BinlogRo;
import com.credithc.customers.dataservice.ro.CustomerAccountInfoRo;
import com.credithc.customers.dataservice.service.CustomerAccountInfoService;
import com.credithc.customers.dataservice.service.SyncDataService;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import tk.mybatis.mapper.entity.Example;

import java.sql.Timestamp;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Service
@Slf4j
public class CustomerAccountInfoServiceImpl implements CustomerAccountInfoService {
    @Autowired
    private ICommonService commonService;
    @Autowired
    private DlrMapper dlrMapper;
    @Autowired
    CustomerProductMapper customerProductMapper;
    @Autowired
    HyrMapper hyrMapper;
    @Autowired
    JhzfMapper jhzfMapper;
    @Autowired
    private MicroloanUserMapper microloanUserMapper;
    @Autowired
    private EntrustUserMapper entrustUserMapper;
    @Autowired
    private UsersMapper usersMapper;
    @Autowired
    private Xhqb2Mapper xhqb2Mapper;
    @Autowired
    private CustomerAccountMapper customerAccountMapper;
    @Autowired
    private SyncDataService syncDataService;
    @Autowired
    private HydMapper hydMapper;
    @Autowired
    private CommonMapper commonMapper;
    @Autowired
    private LesseeMapper lesseeMapper;


    @Override
    public CustomerAccountInfoRo bulidDlrAccount(BinlogRo binlogRo) {
        Map<String,String> beforeMap = new HashMap<>();
        Map<String,String> afterMap = new HashMap<>();
        CustomerAccountInfoRo customerAccountInfoRo = new CustomerAccountInfoRo();
        String eventType = binlogRo.getEventType();
        loadDataMap(binlogRo,CustomerConstants.DLR,CustomerConstants.DLR,beforeMap,afterMap,customerAccountInfoRo);
        initDlrCustomerAcountInfoRo(eventType,beforeMap,afterMap,customerAccountInfoRo);
        return customerAccountInfoRo;
    }

    @Override
    public CustomerAccountInfoRo bulidDlrBankAccount(BinlogRo binlogRo) {
        Map<String,String> beforeMap = new HashMap<>();
        Map<String,String> afterMap = new HashMap<>();
        CustomerAccountInfoRo customerAccountInfoRo = new CustomerAccountInfoRo();
        String eventType = binlogRo.getEventType();
        loadDataMap(binlogRo,CustomerConstants.DLR,CustomerConstants.DLR,beforeMap,afterMap,customerAccountInfoRo);
        initDlrCustomerBankAcountInfoRo(eventType,beforeMap,afterMap,customerAccountInfoRo);
        return customerAccountInfoRo;
    }

    private void initDlrCustomerBankAcountInfoRo(String eventType,Map<String,String> beforeMap,Map<String,String> afterMap, CustomerAccountInfoRo customerAccountInfoRo) {
        if (SyncTypeEnum.UPDATE.getValue().equals(eventType) || SyncTypeEnum.NEW.getValue().equals(eventType)){
            customerAccountInfoRo.setAccountNo(afterMap.get(TableNameConstants.DLR_QM_USER_CARD_BANK_CARD_NO));
            customerAccountInfoRo.setAccountType(CustomerConstants.CUSTOMER_ACCOUNT_TYPE_BANK_CARD);
            customerAccountInfoRo.setUserSourceId(afterMap.get(TableNameConstants.DLR_QM_USER_CARD_USER_ID));
            log.info("开始查表##############################################################################");
            CustomerNoPo byUserId = null;
            try {
                byUserId = dlrMapper.getByUserId(afterMap.get(TableNameConstants.DLR_QM_USER_CARD_USER_ID));
            } catch (Exception e) {
                log.error(e.getMessage());
            }
            customerAccountInfoRo.setCustomerNo(byUserId==null?null:byUserId.getCustomerNo());
            customerAccountInfoRo.setAccountCreateTime(CustomerUtils.dateStr2Timestamp(afterMap.get(TableNameConstants.DLR_PRODUCT_COLUMN_CREATE_TIME)));
            customerAccountInfoRo.setAccountUpdateTime(CustomerUtils.dateStr2Timestamp(afterMap.get(TableNameConstants.DLR_PRODUCT_COLUMN_UPDATE_TIME)));
            customerAccountInfoRo.setAccountStatus(CustomerConstants.STATUS_ACCOUNT_AVAILABLE);
            String sts = afterMap.get(TableNameConstants.DLR_ACCOUNT_BANCK_STS);
            if (!"A".equals(sts)){
                customerAccountInfoRo.setAccountStatus(CustomerConstants.STATUS_ACCOUNT_UNAVAILABLE);
            }
            if(SyncTypeEnum.UPDATE.getValue().equals(eventType)){
                if(!beforeMap.get(TableNameConstants.DLR_QM_USER_CARD_BANK_CARD_NO).equals(afterMap.get(TableNameConstants.DLR_QM_USER_CARD_BANK_CARD_NO))){
                    customerAccountInfoRo.setOldAccountNo(beforeMap.get(TableNameConstants.DLR_QM_USER_CARD_BANK_CARD_NO));
                }
            }
        }else if (SyncTypeEnum.DELETE.getValue().equals(eventType)){
            customerAccountInfoRo.setAccountNo(beforeMap.get(TableNameConstants.DLR_QM_USER_CARD_BANK_CARD_NO));
            customerAccountInfoRo.setUserSourceId(beforeMap.get(TableNameConstants.DLR_QM_USER_CARD_USER_ID));
        }
    }
    private void initDlrCustomerAcountInfoRo(String eventType,Map<String,String> beforeMap,Map<String,String> afterMap, CustomerAccountInfoRo customerAccountInfoRo) {
        if (SyncTypeEnum.UPDATE.getValue().equals(eventType) || SyncTypeEnum.NEW.getValue().equals(eventType)){
            customerAccountInfoRo.setAccountNo(afterMap.get(TableNameConstants.DLR_QM_USER_CUSTOMER_ID));
            customerAccountInfoRo.setCustomerNo(afterMap.get(TableNameConstants.DLR_QM_USER_CUSTOMER_NO));
            String type = afterMap.get(TableNameConstants.DLR_QM_USER_USER_TYPE);
            customerAccountInfoRo.setAccountType(CustomerConstants.DLR_ACCOUNT_TYPE_LEND.equals(type)?CustomerConstants.CUSTOMER_ACCOUNT_TYPE_LEND:CustomerConstants.CUSTOMER_ACCOUNT_TYPE_LOAN);
            Integer userType = Integer.parseInt((String) type);
            customerAccountInfoRo.setUserSourceId(afterMap.get(TableNameConstants.DLR_QM_USER_CARD_USER_ID));
            customerAccountInfoRo.setAccountCreateTime(CustomerUtils.dateStr2Timestamp(afterMap.get(TableNameConstants.DLR_ACCOUNT_CUSTOMER_OPEN_TIME)));
            customerAccountInfoRo.setAccountUpdateTime(CustomerUtils.dateStr2Timestamp(afterMap.get(TableNameConstants.DLR_PRODUCT_COLUMN_UPDATE_TIME)));
            String role;
            if (userType ==Integer.parseInt(CustomerConstants.DLR_ACCOUNT_TYPE_LEND) ){
                role = CustomerConstants.CUSTOMER_ACCOUNT_TYPE_LEND;
            }else{
                role = CustomerConstants.CUSTOMER_ACCOUNT_TYPE_LOAN;
            }
            customerAccountInfoRo.setCustomerRole(role);
            if (StringUtils.isNotBlank(customerAccountInfoRo.getAccountNo())){
                customerAccountInfoRo.setAccountStatus(CustomerConstants.STATUS_ACCOUNT_AVAILABLE);
            }else{
                customerAccountInfoRo.setAccountStatus(CustomerConstants.STATUS_ACCOUNT_UNAVAILABLE);
            }
            if(SyncTypeEnum.UPDATE.getValue().equals(eventType)){
                if(!beforeMap.get(TableNameConstants.DLR_QM_USER_CUSTOMER_NO).equals(afterMap.get(TableNameConstants.DLR_QM_USER_CUSTOMER_NO))){
                    commonService.updateCustomerNo4SyncData(beforeMap.get(TableNameConstants.DLR_QM_LEND_ORDER_USER_ID),afterMap.get(TableNameConstants.DLR_QM_USER_CUSTOMER_NO),afterMap.get(TableNameConstants.DLR_QM_USER_PRECUSTOMER_NO),"DLR","DLR");
                }
                if (StringUtils.isBlank(beforeMap.get(TableNameConstants.DLR_QM_USER_CUSTOMER_ID))){
                    customerAccountInfoRo.setSyncType(SyncTypeEnum.NEW.getValue());
                }
                if(StringUtils.isBlank(afterMap.get(TableNameConstants.DLR_QM_USER_CUSTOMER_ID))){
                    customerAccountInfoRo.setSyncType(SyncTypeEnum.DELETE.getValue());
                }
            }
        }else if (SyncTypeEnum.DELETE.getValue().equals(eventType)){
            customerAccountInfoRo.setAccountNo(beforeMap.get(TableNameConstants.DLR_QM_USER_CUSTOMER_ID));
            customerAccountInfoRo.setUserSourceId(beforeMap.get(TableNameConstants.DLR_QM_USER_CARD_USER_ID));
        }
    }

    @Override
    public CustomerAccountInfoRo bulidHyrAccount(BinlogRo binlogRo) {
        Map<String,String> beforeMap = new HashMap<>();
        Map<String,String> afterMap = new HashMap<>();
        CustomerAccountInfoRo customerAccountInfoRo = new CustomerAccountInfoRo();
        String eventType = binlogRo.getEventType();
        loadDataMap(binlogRo,CustomerConstants.HYR,CustomerConstants.HYR,beforeMap,afterMap,customerAccountInfoRo);
        initHyrCustomerAcountInfoRo(eventType,beforeMap,afterMap,customerAccountInfoRo);
        return customerAccountInfoRo;
    }

    private void initHyrCustomerAcountInfoRo(String eventType, Map<String, String> beforeMap, Map<String, String> afterMap, CustomerAccountInfoRo customerAccountInfoRo) {
        if (SyncTypeEnum.UPDATE.getValue().equals(eventType)){
            String customerNo = afterMap.get(TableNameConstants.HYR_ACCOUNT_CUSTOMER_NO);
            String uid = afterMap.get(TableNameConstants.HYR_ACCOUNT_USER_ID);
            if (StringUtils.isBlank(customerNo)){
                return;
            }
            try {
                customerAccountMapper.updataByUseridAndSign(customerNo,uid);
            } catch (Exception e) {

               //e.printStackTrace();
                log.error(e.getMessage());
            }
            customerAccountInfoRo.setCustomerNo(afterMap.get(TableNameConstants.HYR_ACCOUNT_CUSTOMER_NO));

            customerAccountInfoRo.setUserSourceId(afterMap.get(TableNameConstants.HYR_ACCOUNT_USER_ID));
            HyrUserInfoPo hyrUserInfoPo = hyrMapper.queryHyrUserInfo(afterMap.get(TableNameConstants.HYR_ACCOUNT_USER_ID));
            customerAccountInfoRo.setAccountCreateTime(hyrUserInfoPo.getCreateTime());
            customerAccountInfoRo.setAccountType(CustomerConstants.HYR_ACCOUNT_TYPE_LEND.equals(hyrUserInfoPo.getUserType())?CustomerConstants.CUSTOMER_ACCOUNT_TYPE_LEND:CustomerConstants.CUSTOMER_ACCOUNT_TYPE_LOAN);
            customerAccountInfoRo.setAccountNo(hyrUserInfoPo.getAccountNo());
            Integer userType = hyrUserInfoPo.getUserType();
            String role;
            if (userType ==Integer.parseInt(CustomerConstants.HYR_ACCOUNT_TYPE_LEND) ){
                role = CustomerConstants.CUSTOMER_ACCOUNT_TYPE_LEND;
            }else{
                role = CustomerConstants.CUSTOMER_ACCOUNT_TYPE_LOAN;
            }
            customerAccountInfoRo.setCustomerRole(role);
            if (StringUtils.isNotBlank(customerAccountInfoRo.getAccountNo())){
                customerAccountInfoRo.setAccountStatus(CustomerConstants.STATUS_ACCOUNT_AVAILABLE);
            }else{
                customerAccountInfoRo.setAccountStatus(CustomerConstants.STATUS_ACCOUNT_UNAVAILABLE);
            }

            if (StringUtils.isBlank(beforeMap.get(TableNameConstants.HYR_ACCOUNT_CUSTOMER_NO))){
                customerAccountInfoRo.setSyncType(SyncTypeEnum.NEW.getValue());
            }

        }else if (SyncTypeEnum.DELETE.getValue().equals(eventType)){
            customerAccountInfoRo.setUserSourceId(beforeMap.get(TableNameConstants.HYR_ACCOUNT_USER_ID));
            HyrUserInfoPo hyrUserInfoPo = hyrMapper.queryHyrUserInfo(afterMap.get(TableNameConstants.HYR_ACCOUNT_USER_ID));
            customerAccountInfoRo.setAccountNo(hyrUserInfoPo.getAccountNo());
        }

    }

    @Override
    public CustomerAccountInfoRo bulidHyrBankAccount(BinlogRo binlogRo) {
        Map<String,String> beforeMap = new HashMap<>();
        Map<String,String> afterMap = new HashMap<>();
        CustomerAccountInfoRo customerAccountInfoRo = new CustomerAccountInfoRo();
        String eventType = binlogRo.getEventType();
        loadDataMap(binlogRo,CustomerConstants.HYR,CustomerConstants.HYR,beforeMap,afterMap,customerAccountInfoRo);
        initHyrCustomerBankAcountInfoRo(eventType,beforeMap,afterMap,customerAccountInfoRo);
        return customerAccountInfoRo;

    }
    private void initHyrCustomerBankAcountInfoRo(String eventType, Map<String, String> beforeMap, Map<String, String> afterMap, CustomerAccountInfoRo customerAccountInfoRo) {
        if (SyncTypeEnum.UPDATE.getValue().equals(eventType) || SyncTypeEnum.NEW.getValue().equals(eventType)){
            customerAccountInfoRo.setAccountNo(afterMap.get("cardid"));
            customerAccountInfoRo.setAccountType(CustomerConstants.CUSTOMER_ACCOUNT_TYPE_BANK_CARD);
            customerAccountInfoRo.setUserSourceId(afterMap.get("uid"));

            CustomerNoPo byUserId = null;
            try {
                byUserId = hyrMapper.getByUserId(afterMap.get("uid"));
            } catch (Exception e) {
                log.error(e.getMessage());
            }
            customerAccountInfoRo.setCustomerNo(byUserId==null?null:byUserId.getCustomerNo());

            customerAccountInfoRo.setAccountCreateTime(CustomerUtils.dateStr2Timestamp(afterMap.get(TableNameConstants.HYR_BANK_COLUMN_CREATE_TIME)));
            customerAccountInfoRo.setAccountUpdateTime(CustomerUtils.dateStr2Timestamp(afterMap.get(TableNameConstants.HYR_BANK_COLUMN_UPDATE_TIME)));

            customerAccountInfoRo.setAccountStatus(CustomerConstants.STATUS_ACCOUNT_AVAILABLE);

            if(SyncTypeEnum.UPDATE.getValue().equals(eventType)){
                if(!beforeMap.get("cardid").equals(afterMap.get("cardid"))){
                    customerAccountInfoRo.setOldAccountNo(beforeMap.get("cardid"));
                }
            }
        }else if (SyncTypeEnum.DELETE.getValue().equals(eventType)){
            customerAccountInfoRo.setAccountNo(beforeMap.get("cardid"));
            customerAccountInfoRo.setUserSourceId(beforeMap.get("uid"));
        }
    }

    @Override
    public CustomerAccountInfoRo bulidJhzfBankAccount(BinlogRo binlogRo) {
        CustomerAccountInfoRo customerAccountInfoRo = new CustomerAccountInfoRo();
        String eventType = binlogRo.getEventType();
        if (SyncTypeEnum.UPDATE.getValue().equals(eventType)) {
            Map<String, String> beforeMap = new HashMap<>();
            Map<String, String> afterMap = new HashMap<>();
            loadDataMap(binlogRo, CustomerConstants.JHZF, CustomerConstants.JHZF, beforeMap, afterMap, customerAccountInfoRo);
            customerAccountInfoRo.setAccountType(CustomerConstants.CUSTOMER_ACCOUNT_TYPE_BANK_CARD);
            customerAccountInfoRo.setAccountStatus(CustomerConstants.STATUS_ACCOUNT_AVAILABLE);
            if (StringUtils.isNotBlank(afterMap.get(TableNameConstants.JHZF_USER_BANK_CARD)) &&!afterMap.get(TableNameConstants.JHZF_USER_BANK_CARD).equals(beforeMap.get(TableNameConstants.JHZF_USER_BANK_CARD))){
                customerAccountInfoRo.setAccountNo(afterMap.get(TableNameConstants.JHZF_USER_BANK_CARD));
                customerAccountInfoRo.setOldAccountNo(beforeMap.get(TableNameConstants.JHZF_USER_BANK_CARD));
                customerAccountInfoRo.setSyncType(eventType);
                customerAccountInfoRo.setSystemSign(CustomerConstants.JHZF);
                customerAccountInfoRo.setSubSystemSign(CustomerConstants.JHZF);
                customerAccountInfoRo.setUserSourceId(afterMap.get(TableNameConstants.JHZF_USER_USER_ID));
                customerAccountInfoRo.setCustomerNo(jhzfMapper.getCustomerNo(afterMap.get(TableNameConstants.JHZF_USER_USER_ID)));
            }else if (StringUtils.isBlank(afterMap.get(TableNameConstants.JHZF_USER_BANK_CARD)) && StringUtils.isNotBlank(beforeMap.get(TableNameConstants.JHZF_USER_BANK_CARD))){
                customerAccountInfoRo.setAccountNo(afterMap.get(TableNameConstants.JHZF_USER_BANK_CARD));
                customerAccountInfoRo.setSyncType(SyncTypeEnum.DELETE.getValue());
                customerAccountInfoRo.setSystemSign(CustomerConstants.JHZF);
                customerAccountInfoRo.setSubSystemSign(CustomerConstants.JHZF);
                customerAccountInfoRo.setUserSourceId(afterMap.get(TableNameConstants.JHZF_USER_USER_ID));
            }
        }
        return customerAccountInfoRo;
    }

    @Override
    public CustomerAccountInfoRo bulidJhzfAccount(BinlogRo binlogRo) {
        Map<String,String> beforeMap = new HashMap<>();
        Map<String,String> afterMap = new HashMap<>();
        CustomerAccountInfoRo customerAccountInfoRo = new CustomerAccountInfoRo();
        String eventType = binlogRo.getEventType();
        loadDataMap(binlogRo,CustomerConstants.JHZF,CustomerConstants.JHZF,beforeMap,afterMap,customerAccountInfoRo);
        initJhzfCustomerAcountInfoRo(eventType,beforeMap,afterMap,customerAccountInfoRo);
        return customerAccountInfoRo;
    }

    @Override
    public CustomerAccountInfoRo bulidXdAccount(BinlogRo binlogRo) {
        Map<String,String> beforeMap = new HashMap<>();
        Map<String,String> afterMap = new HashMap<>();
        CustomerAccountInfoRo customerAccountInfoRo = new CustomerAccountInfoRo();
        String eventType = binlogRo.getEventType();
        loadDataMap(binlogRo,CustomerConstants.XD,CustomerConstants.XD,beforeMap,afterMap,customerAccountInfoRo);
        initXdCustomerAcountInfoRo(eventType,beforeMap,afterMap,customerAccountInfoRo);
        return null;
    }

    @Override
    public CustomerAccountInfoRo bulidXtAccount(BinlogRo binlogRo) {
        Map<String,String> beforeMap = new HashMap<>();
        Map<String,String> afterMap = new HashMap<>();
        CustomerAccountInfoRo customerAccountInfoRo = new CustomerAccountInfoRo();
        String eventType = binlogRo.getEventType();
        loadDataMap(binlogRo,CustomerConstants.XT,CustomerConstants.XT,beforeMap,afterMap,customerAccountInfoRo);
        initXtCustomerAcountInfoRo(eventType,beforeMap,afterMap,customerAccountInfoRo);
        return null;
    }

    @Override
    public CustomerAccountInfoRo bulidHhrJkBankAccount(BinlogRo binlogRo) {
        Map<String,String> beforeMap = new HashMap<>();
        Map<String,String> afterMap = new HashMap<>();
        CustomerAccountInfoRo customerAccountInfoRo = new CustomerAccountInfoRo();
        String eventType = binlogRo.getEventType();
        loadDataMap(binlogRo,CustomerConstants.HHR,CustomerConstants.HHR_JK,beforeMap,afterMap,customerAccountInfoRo);
        initHhrJkCustomerAcountBankInfoRo(eventType,beforeMap,afterMap,customerAccountInfoRo);
        return customerAccountInfoRo;
    }

    @Override
    public CustomerAccountInfoRo bulidHhrJkAccount(BinlogRo binlogRo) {
        Map<String,String> beforeMap = new HashMap<>();
        Map<String,String> afterMap = new HashMap<>();
        CustomerAccountInfoRo customerAccountInfoRo = new CustomerAccountInfoRo();
        String eventType = binlogRo.getEventType();
        loadDataMap(binlogRo,CustomerConstants.HHR,CustomerConstants.HHR_JK,beforeMap,afterMap,customerAccountInfoRo);
        initHhrJkCustomerAcountInfoRo(eventType,beforeMap,afterMap,customerAccountInfoRo);
        return customerAccountInfoRo;

    }

    @Override
    public CustomerAccountInfoRo bulidXhqbBankAccount(BinlogRo binlogRo) {
        Map<String,String> beforeMap = new HashMap<>();
        Map<String,String> afterMap = new HashMap<>();
        CustomerAccountInfoRo customerAccountInfoRo = new CustomerAccountInfoRo();
        String eventType = binlogRo.getEventType();
        loadDataMap(binlogRo,CustomerConstants.XHQB,CustomerConstants.XHQB,beforeMap,afterMap,customerAccountInfoRo);
        initXHQBBankCustomerAcountInfoRo(eventType,beforeMap,afterMap,customerAccountInfoRo);
        return customerAccountInfoRo;
    }

    @Override
    public CustomerAccountInfoRo bulidHydBankAcount(BinlogRo binlogRo) {
        Map<String,String> beforeMap = new HashMap<>();
        Map<String,String> afterMap = new HashMap<>();
        CustomerAccountInfoRo customerAccountInfoRo = new CustomerAccountInfoRo();
        String eventType = binlogRo.getEventType();
        loadDataMap(binlogRo,CustomerConstants.HYD,CustomerConstants.HYD,beforeMap,afterMap,customerAccountInfoRo);
        initHYDBankCustomerAcountInfoRo(eventType,beforeMap,afterMap,customerAccountInfoRo);
        return customerAccountInfoRo;
    }

    @Override
    public void bulidChdAccount(BinlogRo binlogRo) {
        Map<String,String> beforeMap = new HashMap<>();
        Map<String,String> afterMap = new HashMap<>();
        CustomerAccountInfoRo customerAccountInfoRo = new CustomerAccountInfoRo();
        String eventType = binlogRo.getEventType();
        loadDataMap(binlogRo,"CHD","CHD",beforeMap,afterMap,customerAccountInfoRo);
        initCHDBankCustomerAcountInfoRo(eventType,beforeMap,afterMap,customerAccountInfoRo);
    }

    @Override
    public void bulidHHRCJAccount(BinlogRo binlogRo) {
        Map<String,String> beforeMap = new HashMap<>();
        Map<String,String> afterMap = new HashMap<>();
        CustomerAccountInfoRo customerAccountInfoRo = new CustomerAccountInfoRo();
        String eventType = binlogRo.getEventType();
        loadDataMap(binlogRo,"HHR","HHR_CF",beforeMap,afterMap,customerAccountInfoRo);
        initHHRCFBankCustomerAcountInfoRo(eventType,beforeMap,afterMap,customerAccountInfoRo);
    }

    private void initHHRCFBankCustomerAcountInfoRo(String eventType, Map<String, String> beforeMap, Map<String, String> afterMap, CustomerAccountInfoRo customerAccountInfoRo) {

        if (SyncTypeEnum.UPDATE.getValue().equals(eventType) || SyncTypeEnum.NEW.getValue().equals(eventType)){
            customerAccountInfoRo.setAccountNo(afterMap.get("account_no"));

            customerAccountInfoRo.setAccountCreateTime(CustomerUtils.dateStr2Timestamp(afterMap.get("u_addtime")));
            if (1 == Integer.valueOf(afterMap.get("user_role"))){
                customerAccountInfoRo.setAccountType(CustomerConstants.CUSTOMER_ACCOUNT_TYPE_LEND);
                customerAccountInfoRo.setCustomerRole(CustomerConstants.CUSTOMER_ACCOUNT_TYPE_LEND);
            }else{
                customerAccountInfoRo.setAccountType(CustomerConstants.CUSTOMER_ACCOUNT_TYPE_LOAN);
                customerAccountInfoRo.setCustomerRole(CustomerConstants.CUSTOMER_ACCOUNT_TYPE_LOAN);
            }
            customerAccountInfoRo.setAccountStatus(CustomerConstants.STATUS_ACCOUNT_AVAILABLE);
            customerAccountInfoRo.setUserSourceId(afterMap.get("u_id"));
            customerAccountInfoRo.setCustomerNo(afterMap.get("customerno"));
            if(SyncTypeEnum.UPDATE.getValue().equals(eventType)){
                customerAccountInfoRo.setOldAccountNo(beforeMap.get("account_no"));
            }
            if (StringUtils.isNotBlank(customerAccountInfoRo.getAccountNo())&& StringUtils.isNotBlank(customerAccountInfoRo.getCustomerNo())) {
                syncDataService.syncCustomerAccount(customerAccountInfoRo);
            }
            customerAccountInfoRo.setAccountType(CustomerConstants.CUSTOMER_ACCOUNT_TYPE_BANK_CARD);
            customerAccountInfoRo.setAccountNo(afterMap.get("a_card_num"));
            customerAccountInfoRo.setCustomerRole(null);
            if(SyncTypeEnum.UPDATE.getValue().equals(eventType)){
                customerAccountInfoRo.setOldAccountNo(beforeMap.get("a_card_num"));
            }
            if (StringUtils.isNotBlank(customerAccountInfoRo.getAccountNo())&& StringUtils.isNotBlank(customerAccountInfoRo.getCustomerNo())) {
                syncDataService.syncCustomerAccount(customerAccountInfoRo);
            }
        }else if (SyncTypeEnum.DELETE.getValue().equals(eventType)){
            customerAccountInfoRo.setAccountNo(beforeMap.get("a_card_num"));
            customerAccountInfoRo.setUserSourceId(beforeMap.get("u_id"));
            syncDataService.syncCustomerAccount(customerAccountInfoRo);
            customerAccountInfoRo.setAccountNo(beforeMap.get("account_no"));
            customerAccountInfoRo.setUserSourceId(beforeMap.get("u_id"));
            syncDataService.syncCustomerAccount(customerAccountInfoRo);
        }

    }

    private void initCHDBankCustomerAcountInfoRo(String eventType, Map<String, String> beforeMap, Map<String, String> afterMap, CustomerAccountInfoRo customerAccountInfoRo) {
        if (SyncTypeEnum.UPDATE.getValue().equals(eventType) || SyncTypeEnum.NEW.getValue().equals(eventType)){
            try {
                customerAccountInfoRo.setAccountCreateTime((new Timestamp(Long.valueOf(afterMap.get("create_at")))));
            } catch (NumberFormatException e) {
            }
            customerAccountInfoRo.setAccountType(CustomerConstants.CUSTOMER_ACCOUNT_TYPE_BANK_CARD);
            customerAccountInfoRo.setCustomerRole(CustomerConstants.CUSTOMER_ACCOUNT_TYPE_LOAN);

            Example e = new Example(CHDCommonPO.class);
            Example.Criteria criteria = e.createCriteria();
            criteria.andEqualTo("contractCode",afterMap.get("contract_code"));
            CHDCommonPO chdCommon = null;
            try {
                chdCommon = commonMapper.selectOneByExample(e);
            } catch (Exception e1) {
                List<CHDCommonPO> chdCommonPOS = commonMapper.selectByExample(e);
                if (chdCommonPOS!=null && chdCommonPOS.size()>0) {
                    chdCommon = chdCommonPOS.get(chdCommonPOS.size() - 1);
                }
            }
            if (chdCommon != null ){
                Example l = new Example(CHDLesseePO.class);
                Example.Criteria lc = l.createCriteria();
                lc.andEqualTo("businessId",chdCommon.getId());
                CHDLesseePO chdLesseePO = lesseeMapper.selectOneByExample(l);
                if (chdLesseePO != null && StringUtils.isNotBlank(chdLesseePO.getCustomerNo())){
                    customerAccountInfoRo.setCustomerNo(chdLesseePO.getCustomerNo());
                    customerAccountInfoRo.setUserSourceId("CHD"+ chdLesseePO.getCustomerNo());
                    customerAccountInfoRo.setAccountStatus(CustomerConstants.STATUS_ACCOUNT_AVAILABLE);

                    customerAccountInfoRo.setAccountNo(afterMap.get("pay_account"));
                    if(SyncTypeEnum.UPDATE.getValue().equals(eventType)){
                        customerAccountInfoRo.setOldAccountNo(beforeMap.get("pay_account"));
                    }
                    if (StringUtils.isNotBlank(customerAccountInfoRo.getAccountNo())) {
                        syncDataService.syncCustomerAccount(customerAccountInfoRo);
                    }
                    CustomerAccountInfoRo customerAccountInfoRo1 = new CustomerAccountInfoRo();
                    BeanUtils.copyProperties(customerAccountInfoRo,customerAccountInfoRo1);
                    customerAccountInfoRo1.setAccountNo(afterMap.get("recei_account"));
                    if(SyncTypeEnum.UPDATE.getValue().equals(eventType)){
                        customerAccountInfoRo1.setOldAccountNo(beforeMap.get("recei_account"));
                    }
                    if (StringUtils.isNotBlank(customerAccountInfoRo1.getAccountNo())){
                        syncDataService.syncCustomerAccount(customerAccountInfoRo1);
                    }
                }
            }
        }else if (SyncTypeEnum.DELETE.getValue().equals(eventType)) {

        }
    }

    private void initHYDBankCustomerAcountInfoRo(String eventType, Map<String, String> beforeMap, Map<String, String> afterMap, CustomerAccountInfoRo customerAccountInfoRo) {
        if (SyncTypeEnum.UPDATE.getValue().equals(eventType) || SyncTypeEnum.NEW.getValue().equals(eventType)){
            customerAccountInfoRo.setAccountNo(afterMap.get("card_number"));
            customerAccountInfoRo.setAccountCreateTime(CustomerUtils.dateStr2Timestamp(afterMap.get("auth_time")));
            customerAccountInfoRo.setAccountType(CustomerConstants.CUSTOMER_ACCOUNT_TYPE_BANK_CARD);
            customerAccountInfoRo.setCustomerRole(CustomerConstants.CUSTOMER_ACCOUNT_TYPE_LOAN);
            customerAccountInfoRo.setUserSourceId(afterMap.get("user_id"));

            CustomerNoPo user_id = hydMapper.getByUserId(afterMap.get("user_id"));
            if (user_id != null){
                customerAccountInfoRo.setCustomerNo(user_id.getCustomerNo());
            }

            if (StringUtils.isNotBlank(customerAccountInfoRo.getAccountNo())){
                customerAccountInfoRo.setAccountStatus(CustomerConstants.STATUS_ACCOUNT_AVAILABLE);
            }else{
                customerAccountInfoRo.setAccountStatus(CustomerConstants.STATUS_ACCOUNT_UNAVAILABLE);
            }
            if(SyncTypeEnum.UPDATE.getValue().equals(eventType)){
                customerAccountInfoRo.setOldAccountNo(beforeMap.get("card_number"));
            }
        }else if (SyncTypeEnum.DELETE.getValue().equals(eventType)){
            customerAccountInfoRo.setAccountNo(beforeMap.get("card_number"));
            customerAccountInfoRo.setUserSourceId(beforeMap.get("user_id"));
        }
    }

    private void initXHQBBankCustomerAcountInfoRo(String eventType, Map<String, String> beforeMap, Map<String, String> afterMap, CustomerAccountInfoRo customerAccountInfoRo) {
        if (SyncTypeEnum.UPDATE.getValue().equals(eventType) || SyncTypeEnum.NEW.getValue().equals(eventType)){
            customerAccountInfoRo.setAccountNo(afterMap.get("bankcard_number"));
            customerAccountInfoRo.setAccountCreateTime(CustomerUtils.dateStr2Timestamp(afterMap.get("create_date")));
            customerAccountInfoRo.setAccountType(CustomerConstants.CUSTOMER_ACCOUNT_TYPE_BANK_CARD);
            customerAccountInfoRo.setUserSourceId(afterMap.get("user_id"));
            customerAccountInfoRo.setCustomerRole(CustomerConstants.CUSTOMER_ACCOUNT_TYPE_LOAN);
            CustomerNoPo user_id = xhqb2Mapper.getByUserId(afterMap.get("user_id"));
            if (user_id!=null) {
                customerAccountInfoRo.setCustomerNo(user_id.getCustomerNo());
            }
            if (StringUtils.isNotBlank(customerAccountInfoRo.getAccountNo())){
                customerAccountInfoRo.setAccountStatus(CustomerConstants.STATUS_ACCOUNT_AVAILABLE);
            }else{
                customerAccountInfoRo.setAccountStatus(CustomerConstants.STATUS_ACCOUNT_UNAVAILABLE);
            }
            if(SyncTypeEnum.UPDATE.getValue().equals(eventType)){
                customerAccountInfoRo.setOldAccountNo(beforeMap.get("bankcard_number"));
            }
        }else if (SyncTypeEnum.DELETE.getValue().equals(eventType)){
            customerAccountInfoRo.setAccountNo(beforeMap.get("bankcard_number"));
            customerAccountInfoRo.setUserSourceId(beforeMap.get("user_id"));
        }
    }

    private void initHhrJkCustomerAcountInfoRo(String eventType, Map<String, String> beforeMap, Map<String, String> afterMap, CustomerAccountInfoRo customerAccountInfoRo) {

        if (SyncTypeEnum.UPDATE.getValue().equals(eventType) || SyncTypeEnum.NEW.getValue().equals(eventType)){
            customerAccountInfoRo.setAccountNo(afterMap.get(TableNameConstants.HHR_JK_ACCOUNT_NO));
            try {
                customerAccountInfoRo.setAccountCreateTime(CustomerUtils.dateStr2Timestamp(afterMap.get(TableNameConstants.HHR_JK_ACCOUNT_CREATE_TIME)));
            } catch (NumberFormatException e) {
                e.printStackTrace();
            }
            customerAccountInfoRo.setAccountType(CustomerConstants.CUSTOMER_ACCOUNT_TYPE_LOAN);

            customerAccountInfoRo.setCustomerNo(afterMap.get(TableNameConstants.HHR_JK_CUSTOMER_NO));
            customerAccountInfoRo.setUserSourceId(afterMap.get(TableNameConstants.HHR_JK_BANK_USERID));
            customerAccountInfoRo.setCustomerRole(CustomerConstants.CUSTOMER_ACCOUNT_TYPE_LOAN);

            if (StringUtils.isNotBlank(customerAccountInfoRo.getAccountNo())){
                customerAccountInfoRo.setAccountStatus(CustomerConstants.STATUS_ACCOUNT_AVAILABLE);
            }else{
                customerAccountInfoRo.setAccountStatus(CustomerConstants.STATUS_ACCOUNT_UNAVAILABLE);
            }
            if(SyncTypeEnum.UPDATE.getValue().equals(eventType)){
                customerAccountInfoRo.setOldAccountNo(beforeMap.get(TableNameConstants.HHR_JK_ACCOUNT_NO));
            }
        }else if (SyncTypeEnum.DELETE.getValue().equals(eventType)){
            customerAccountInfoRo.setAccountNo(beforeMap.get(TableNameConstants.HHR_JK_ACCOUNT_NO));
            customerAccountInfoRo.setUserSourceId(beforeMap.get(TableNameConstants.HHR_JK_BANK_USERID));
        }
    }

    private void initHhrJkCustomerAcountBankInfoRo(String eventType, Map<String, String> beforeMap, Map<String, String> afterMap, CustomerAccountInfoRo customerAccountInfoRo) {
        if (SyncTypeEnum.UPDATE.getValue().equals(eventType) || SyncTypeEnum.NEW.getValue().equals(eventType)){
            customerAccountInfoRo.setAccountNo(afterMap.get(TableNameConstants.HHR_JK_BANK_NO));
            customerAccountInfoRo.setAccountStatus(Integer.valueOf(afterMap.get("status")) == 1 ? CustomerConstants.STATUS_ACCOUNT_AVAILABLE:CustomerConstants.STATUS_ACCOUNT_UNAVAILABLE);
            try {
                customerAccountInfoRo.setAccountCreateTime(new Timestamp(Long.valueOf(afterMap.get(TableNameConstants.HHR_JK_BANK_CREATE_TIME))*1000));
            } catch (NumberFormatException e) {

            }
            customerAccountInfoRo.setAccountType(CustomerConstants.CUSTOMER_ACCOUNT_TYPE_BANK_CARD);

            Example example = new Example(HHRCJUsersPO.class);
            Example.Criteria criteria = example.createCriteria();
            String userid = afterMap.get(TableNameConstants.HHR_JK_BANK_USERID);
            criteria.andEqualTo("userid",userid);
            HHRCJUsersPO hhrcjUsersPO = usersMapper.selectOneByExample(example);
            if (hhrcjUsersPO != null){
                customerAccountInfoRo.setCustomerNo(hhrcjUsersPO.getCustomerNo());
                customerAccountInfoRo.setUserSourceId(hhrcjUsersPO.getUserid());
            }

            customerAccountInfoRo.setCustomerRole(CustomerConstants.CUSTOMER_ACCOUNT_TYPE_LOAN);
       /*     if (StringUtils.isNotBlank(customerAccountInfoRo.getAccountNo())){
                customerAccountInfoRo.setAccountStatus(CustomerConstants.STATUS_ACCOUNT_AVAILABLE);
            }else{
                customerAccountInfoRo.setAccountStatus(CustomerConstants.STATUS_ACCOUNT_UNAVAILABLE);
            }*/
            if(SyncTypeEnum.UPDATE.getValue().equals(eventType)){
                customerAccountInfoRo.setOldAccountNo(beforeMap.get(TableNameConstants.HHR_JK_BANK_NO));
            }
        }else if (SyncTypeEnum.DELETE.getValue().equals(eventType)){
            customerAccountInfoRo.setAccountNo(beforeMap.get(TableNameConstants.HHR_JK_BANK_NO));
            customerAccountInfoRo.setUserSourceId(beforeMap.get(TableNameConstants.HHR_JK_BANK_USERID));
        }
    }

    private void initXtCustomerAcountInfoRo(String eventType, Map<String, String> beforeMap, Map<String, String> afterMap, CustomerAccountInfoRo customerAccountInfoRo) {
        if (SyncTypeEnum.UPDATE.getValue().equals(eventType) || SyncTypeEnum.NEW.getValue().equals(eventType)){
            customerAccountInfoRo.setAccountNo(afterMap.get(TableNameConstants.XD_CARD_NO));
            customerAccountInfoRo.setAccountType(CustomerConstants.CUSTOMER_ACCOUNT_TYPE_BANK_CARD);
            customerAccountInfoRo.setAccountCreateTime( CustomerUtils.dateStr2Timestamp(afterMap.get(TableNameConstants.XD_BANK_CREATE_TIME)));
            customerAccountInfoRo.setAccountUpdateTime(CustomerUtils.dateStr2Timestamp(afterMap.get(TableNameConstants.XD_BANK_UPDATE_TIME)));

            customerAccountInfoRo.setAccountStatus(Integer.valueOf(afterMap.get("bind_state")) == 300 ?CustomerConstants.STATUS_ACCOUNT_AVAILABLE:CustomerConstants.STATUS_ACCOUNT_UNAVAILABLE );
            customerAccountInfoRo.setCustomerRole(CustomerConstants.CUSTOMER_ACCOUNT_TYPE_LOAN);
            if(SyncTypeEnum.UPDATE.getValue().equals(eventType)){
                customerAccountInfoRo.setOldAccountNo(beforeMap.get(TableNameConstants.XD_CARD_NO));
            }
            Example example = new Example(EntrustUserPO.class);
            Example.Criteria criteria = example.createCriteria();
            String cardNo = afterMap.get(TableNameConstants.XD_BANK_USER_CARD);
            criteria.andEqualTo("idCard",cardNo);
            List<EntrustUserPO> entrustUserPOS = entrustUserMapper.selectByExample(example);
            for (EntrustUserPO entrustUserPO:entrustUserPOS) {
                customerAccountInfoRo.setSubSystemSign(entrustUserPO.getSubSystem()+CustomerConstants.XT);
                customerAccountInfoRo.setCustomerNo(entrustUserPO.getCustomerNo());
                customerAccountInfoRo.setUserSourceId(entrustUserPO.getId());
                if (StringUtils.isNotBlank(customerAccountInfoRo.getCustomerNo())&&StringUtils.isNotBlank(customerAccountInfoRo.getAccountNo()) &&!"0".equals(customerAccountInfoRo.getCustomerNo())) {
                    syncDataService.syncCustomerAccount(customerAccountInfoRo);
                }
            }


        }else if (SyncTypeEnum.DELETE.getValue().equals(eventType)){
            customerAccountInfoRo.setAccountNo(beforeMap.get(TableNameConstants.XD_CARD_NO));
            Example example = new Example(EntrustUserPO.class);
            Example.Criteria criteria = example.createCriteria();
            String cardNo = beforeMap.get(TableNameConstants.XD_BANK_USER_CARD);
            criteria.andEqualTo("idCard",cardNo);
            List<EntrustUserPO> entrustUserPOS = entrustUserMapper.selectByExample(example);
            for (EntrustUserPO entrustUserPO:entrustUserPOS) {
                customerAccountInfoRo.setSubSystemSign(entrustUserPO.getSubSystem() + CustomerConstants.XT);
                customerAccountInfoRo.setUserSourceId(entrustUserPO.getId());
                syncDataService.syncCustomerAccount(customerAccountInfoRo);
            }
        }

    }

    private void initXdCustomerAcountInfoRo(String eventType, Map<String, String> beforeMap, Map<String, String> afterMap, CustomerAccountInfoRo customerAccountInfoRo) {

        if (SyncTypeEnum.UPDATE.getValue().equals(eventType) || SyncTypeEnum.NEW.getValue().equals(eventType)){
            customerAccountInfoRo.setAccountNo(afterMap.get(TableNameConstants.XD_CARD_NO));
            customerAccountInfoRo.setAccountType(CustomerConstants.CUSTOMER_ACCOUNT_TYPE_BANK_CARD);
            customerAccountInfoRo.setAccountStatus(Integer.valueOf(afterMap.get("bind_state")) == 300 ?CustomerConstants.STATUS_ACCOUNT_AVAILABLE:CustomerConstants.STATUS_ACCOUNT_UNAVAILABLE );
            Example example = new Example(MicroloanUserPO.class);
            Example.Criteria criteria = example.createCriteria();
            String cardNo = afterMap.get(TableNameConstants.XD_BANK_USER_CARD);
            criteria.andEqualTo("idCard",cardNo);
            List<MicroloanUserPO> microloanUserPOS = microloanUserMapper.selectByExample(example);
            customerAccountInfoRo.setCustomerRole(CustomerConstants.CUSTOMER_ACCOUNT_TYPE_LOAN);
            if(SyncTypeEnum.UPDATE.getValue().equals(eventType)){
                customerAccountInfoRo.setOldAccountNo(beforeMap.get(TableNameConstants.XD_CARD_NO));
            }
            for (MicroloanUserPO microloanUserPO:microloanUserPOS) {
                customerAccountInfoRo.setSubSystemSign(microloanUserPO.getSubSystem());
                if (StringUtils.isNotBlank(afterMap.get(TableNameConstants.XD_BANK_CREATE_TIME))) {
                    customerAccountInfoRo.setAccountCreateTime(new Timestamp(Long.valueOf(afterMap.get(TableNameConstants.XD_BANK_CREATE_TIME))));
                }
                if (StringUtils.isNotBlank(afterMap.get(TableNameConstants.XD_BANK_UPDATE_TIME))) {
                    customerAccountInfoRo.setAccountUpdateTime(new Timestamp(Long.valueOf(afterMap.get(TableNameConstants.XD_BANK_UPDATE_TIME))));
                }
                if (microloanUserPO != null){
                    customerAccountInfoRo.setCustomerNo(microloanUserPO.getCustomerNo());
                    customerAccountInfoRo.setUserSourceId(microloanUserPO.getId());
                }
                if (StringUtils.isNotBlank(customerAccountInfoRo.getAccountNo()) && StringUtils.isNotBlank(customerAccountInfoRo.getCustomerNo()) &&!"0".equals(customerAccountInfoRo.getCustomerNo())){
                    syncDataService.syncCustomerAccount(customerAccountInfoRo);
                    log.info("------------------预备向账户表添加一条记录----------------------");
                }
            }


        }else if (SyncTypeEnum.DELETE.getValue().equals(eventType)){
            customerAccountInfoRo.setAccountNo(beforeMap.get(TableNameConstants.XD_CARD_NO));
            Example example = new Example(MicroloanUserPO.class);
            Example.Criteria criteria = example.createCriteria();
            String cardNo = beforeMap.get(TableNameConstants.XD_BANK_USER_CARD);
            criteria.andEqualTo("idCard",cardNo);
            List<MicroloanUserPO> microloanUserPOS = microloanUserMapper.selectByExample(example);
            for (MicroloanUserPO microloanUserPO:microloanUserPOS) {
                customerAccountInfoRo.setSubSystemSign(microloanUserPO.getSubSystem());
                customerAccountInfoRo.setUserSourceId(microloanUserPO.getId());
                syncDataService.syncCustomerAccount(customerAccountInfoRo);
            }

        }

    }

    private void initJhzfCustomerAcountInfoRo(String eventType, Map<String, String> beforeMap, Map<String, String> afterMap, CustomerAccountInfoRo customerAccountInfoRo) {
        if (SyncTypeEnum.UPDATE.getValue().equals(eventType) || SyncTypeEnum.NEW.getValue().equals(eventType)){
            customerAccountInfoRo.setCustomerNo(afterMap.get(TableNameConstants.JHZF_CUSTOMER_NO));
            customerAccountInfoRo.setAccountType(CustomerConstants.CUSTOMER_ACCOUNT_TYPE_BANK_CARD);
            String userId = afterMap.get(TableNameConstants.JHZF_USER_USER_ID);
            customerAccountInfoRo.setUserSourceId(userId);
            if (StringUtils.isNotBlank(userId)){
                JhzfBankPo jhzfBankPo = jhzfMapper.getByUserId(userId);
                if (jhzfBankPo!=null) {
                    customerAccountInfoRo.setAccountNo(jhzfBankPo.getBankCard());
                    customerAccountInfoRo.setAccountCreateTime(jhzfBankPo.getCreatTime());
                    customerAccountInfoRo.setAccountUpdateTime(jhzfBankPo.getUpdateTime());
                }
            }
            if (StringUtils.isNotBlank(customerAccountInfoRo.getAccountNo())){
                customerAccountInfoRo.setAccountStatus(CustomerConstants.STATUS_ACCOUNT_AVAILABLE);
            }else{
                customerAccountInfoRo.setAccountStatus(CustomerConstants.STATUS_ACCOUNT_UNAVAILABLE);
            }

            if(SyncTypeEnum.UPDATE.getValue().equals(eventType)){
                if (StringUtils.isBlank(beforeMap.get(TableNameConstants.DLR_QM_USER_CUSTOMER_ID))){
                    customerAccountInfoRo.setSyncType(SyncTypeEnum.NEW.getValue());
                }
                if(StringUtils.isBlank(afterMap.get(TableNameConstants.DLR_QM_USER_CUSTOMER_ID))){
                    customerAccountInfoRo.setSyncType(SyncTypeEnum.DELETE.getValue());
                }
            }
        }else if (SyncTypeEnum.DELETE.getValue().equals(eventType)){
            if (StringUtils.isNotBlank(beforeMap.get(TableNameConstants.JHZF_USER_USER_ID))){
                JhzfBankPo jhzfBankPo = jhzfMapper.getByUserId(beforeMap.get(TableNameConstants.JHZF_USER_USER_ID));
                customerAccountInfoRo.setAccountNo(jhzfBankPo.getBankCard());
            }

            customerAccountInfoRo.setUserSourceId(beforeMap.get(TableNameConstants.JHZF_USER_USER_ID));
        }
    }

    private void loadDataMap(BinlogRo binlogRo, String systemSign, String subSystrmSign, Map<String,String> beforeMap, Map<String,String> afterMap, CustomerAccountInfoRo customerAccountInfoRo) {
        String eventType = binlogRo.getEventType();
        customerAccountInfoRo.setSyncType(eventType);
        customerAccountInfoRo.setSubSystemSign(subSystrmSign);
        customerAccountInfoRo.setSystemSign(systemSign);
        List<BinlogColumnRo> afterColumns = binlogRo.getRows().getAfterColumns();
        List<BinlogColumnRo> beforeColumns = binlogRo.getRows().getBeforeColumns();

        for (BinlogColumnRo c:beforeColumns) {
            beforeMap.put(c.getName(), (String) c.getValue());
        }
        for (BinlogColumnRo c:afterColumns) {
            afterMap.put(c.getName(), (String) c.getValue());
        }
    }
}
